﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="BankTransactions.ascx.cs"
    Inherits="TCKQKL.FrontEnd.Web.Controls.BankTransactions" %>
<link href="../styles/data.css" rel="stylesheet" type="text/css" />
<%@ Import Namespace="TCKQKL.FrontEnd.DataModel" %>
<%@ Import Namespace="TCKQKL.FrontEnd.Config" %>

<script src="../javascript/TCKQKL.FrontEnd.Web.CalendarPopup.js" type="text/javascript"></script>

<script src="../javascript/TCKQKL.FrontEnd.Web.Common.js" type="text/javascript"></script>

<table style="width: 100%;">
    <tr>
        <td colspan="5">
            <table>
                <tr>
                    <td>
                        Từ ngày:
                    </td>
                    <td>

                        <script type="text/javascript" language="JavaScript">
                           var cal = new CalendarPopup();
                        </script>

                        <asp:TextBox CssClass="textShort" Style="vertical-align: top; float: left; height: 17px;
                            width: 80px;" ID="date1" runat="server"></asp:TextBox>
                        <img style="vertical-align: top; float: left;" id="anchor1" onclick="cal.select(document.forms['aspnetForm'].ctl00_ContentPlaceHolder1_BankTransactions1_date1,'anchor1','MM/dd/yyyy'); return false;"
                            src="./Images/selectdate.gif" alt="select" />
                    </td>
                    <td>
                        Đến ngày:
                    </td>
                    <td>
                        <asp:TextBox CssClass="textShort" Style="vertical-align: top; float: left; height: 17px;
                            width: 80px;" ID="date2" runat="server"></asp:TextBox>
                        <img style="vertical-align: top; float: left;" id="anchor2" onclick="cal.select(document.forms['aspnetForm'].ctl00_ContentPlaceHolder1_BankTransactions1_date2,'anchor2','MM/dd/yyyy'); return false;"
                            src="./Images/selectdate.gif" alt="select" />
                    </td>
                    <td>
                        <asp:Button ID="Button1" runat="server" Text="Thực hiện" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td id="middle" style="width: 100%; vertical-align: top;" colspan="5">
            <table class="data">
                <tr>
                    <th rowspan="2" style="text-align: center; border-right: 1px solid #ccc">
                        Ngày
                    </th>
                    <th rowspan="2" style="text-align: center; border-right: 1px solid #ccc" colspan="2">
                        Nội dung giao dịch
                    </th>
                    <th style="text-align: center; border-right: 1px solid #ccc" colspan="3">
                        Chứng khoán
                    </th>
                    <th colspan="3" style="text-align: center;">
                        Tiền
                    </th>
                </tr>
                <tr>
                    <th style="text-align: center; border-right: 1px solid #ccc">
                        MCK
                    </th>
                    <th class="InnerHeading" style="text-align: center; border-right: 1px solid #ccc">
                        PS tăng
                    </th>
                    <th class="InnerHeading" style="text-align: center; border-right: 1px solid #ccc">
                        PS giảm
                    </th>
                    <th class="InnerHeading" style="text-align: center; border-right: 1px solid #ccc">
                        PS tăng
                    </th>
                    <th class="InnerHeading" style="text-align: center;">
                        PS giảm
                    </th>
                    <th class="InnerHeading" style="border-left: 1px solid #ccc">
                        Số dư
                    </th>
                </tr>
                <tr>
                    <td colspan="9">
                        <table class="data">
                            <tr>
                                <th colspan="8" style="font-weight: bold; text-align: left;">
                                    Số dư đầu kỳ
                                </th>
                                <th>
                                    <%=(remainStart != 0) ? String.Format("{0:0,0}", remainStart) : String.Empty%>
                                </th>
                            </tr>
                        </table>
                    </td>
                </tr>
                <% remainEnd = remainStart;
                   if (trans.Count > 0)
                   {
                       for (int i = 0; i < trans.Count; i++)
                       {
                           totalIncAmount += trans[i].IncreaseAmount;
                           totalDecAmount += trans[i].DecreaseAmount;
                           remainEnd = trans[i].Remain;%>
                <tr>
                    <td class="InnerData" style="width: 60px; ">
                        <%=trans[i].Date.ToString("dd/MM/yyyy")%>
                    </td>
                    <td style="white-space: normal; border-left: 1px solid #ccc" colspan="2">
                        <%=trans[i].TransText%>
                    </td>
                    <td class="InnerData" style="font-weight: bold; text-align: center; width: 50px; border-left: 1px solid #ccc">
                        <%=trans[i].Code%>
                    </td>
                    <td class="InnerData" style="color: green; width: 50px;border-left: 1px solid #ccc">
                        <%=(trans[i].IncreaseQtty != 0) ? String.Format("{0:0,0}", trans[i].IncreaseQtty) : String.Empty%>
                    </td>
                    <td class="InnerData" style="color: red; width: 50px;border-left: 1px solid #ccc ">
                        <%=(trans[i].DecreaseQtty != 0) ? String.Format("{0:0,0}", trans[i].DecreaseQtty) : String.Empty%>
                    </td>
                    <td class="InnerData" style="color: green; width: 70px;border-left: 1px solid #ccc">
                        <%=(trans[i].IncreaseAmount != 0) ? String.Format("{0:0,0}", trans[i].IncreaseAmount) : String.Empty%>
                    </td>
                    <td class="InnerData" style="color: red; width: 70px; border-left: 1px solid #ccc">
                        <%=(trans[i].DecreaseAmount != 0) ? String.Format("{0:0,0}", trans[i].DecreaseAmount) : String.Empty%>
                    </td>
                    <td class="InnerData" style="width: 80px; border-left: 1px solid #ccc">
                        <div title="<%=trans[i].Note %>">
                            <%=(trans[i].Remain != 0) ? String.Format("{0:0,0}", trans[i].Remain) : String.Empty%></div>
                    </td>
                </tr>
                <%}
                   } %>
                <tr>
                    <td colspan="6" style="font-weight: bold; text-align: right; font-size: 8pt;">
                        Tổng hợp
                    </td>
                    <td style="color: green; font-weight: bold; border-left: 1px solid #ccc" class="InnerData">
                        <%=(totalIncAmount != 0) ? String.Format("{0:0,0}", totalIncAmount) : String.Empty%>
                    </td>
                    <td style="color: red; font-weight: bold; border-left: 1px solid #ccc" class="InnerData">
                        <%=(totalDecAmount != 0) ? String.Format("{0:0,0}", totalDecAmount) : String.Empty%>
                    </td>
                    <td style="font-weight: bold;border-left: 1px solid #ccc;" class="InnerData">
                        <%=(remainEnd != 0) ? String.Format("{0:0,0}", remainEnd) : String.Empty%>
                    </td>
                </tr>
                <%if (bankData != null)
                  { %>
                <tr>
                    <td colspan="9">
                        <table class="data">
                            <tr>
                                <th>
                                    Số dư chờ thanh toán
                                </th>
                                <th style="color: red">
                                    <%=(bankData.blockAmount != 0) ? String.Format("{0:0,0}", bankData.blockAmount) : String.Empty%>
                                </th>
                                <th>
                                    Số dư chờ về
                                </th>
                                <th style="color: green;">
                                    <%=(nettingAmount != 0) ? String.Format("{0:0,0}", nettingAmount) : String.Empty%>
                                </th>
                                <th colspan="">
                                    Số dư có thể sử dụng
                                </th>
                                <th style="color: green">
                                    <%=((remainEnd - bankData.blockAmount) != 0) ? String.Format("{0:0,0}", remainEnd - bankData.blockAmount) : String.Empty%>
                                </th>
                            </tr>
                        </table>
                    </td>
                </tr>
                <%} %>
            </table>
        </td>
    </tr>
</table>
